﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/1/2009
 * Time: 11:41 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Buaya.Model;

namespace Buaya.Gui
{
	/// <summary>
	/// Description of ToDoForm.
	/// </summary>
	public partial class ToDoForm : BaseForm
	{
		public ToDoForm() : this(new ToDo())
		{
			
		}
		
		public ToDoForm(ToDo t)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = t;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			ToDo t = Model as ToDo;
			richTextBoxNote.Text = t.Note;
			dateTimePickerRemindOn.Value = t.RemindOn;
			checkBoxDone.Checked = t.Done;
			checkBoxInactive.Checked = t.Inactive;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			ToDo t = Model as ToDo;
			t.Note = richTextBoxNote.Text;
			t.RemindOn = dateTimePickerRemindOn.Value;
			t.Done = checkBoxDone.Checked;
			t.Inactive = checkBoxInactive.Checked;
			SessionFacade.SaveOrUpdateToDo(t);
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
